home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World 2007 July & August
/
PCWorld_2007-07-08_cd.bin
/
komunikace
/
maxthon
/
mcombo.exe
/
Plugin
/
Del.icio.us Sidebar
/
scripts
/
MaxthonLibrary.js
< prev
next >
Wrap
Text File
|
2006-09-02
|
3KB
|
116 lines
/**************************
Del.icio.us Sidebar
By Neo101
Version 1.1.0
**************************/
var SECURITY_ID = max_security_id
var PLUGIN_NAME = "Del.icio.us Sidebar"
var alreadyShowingError = false
window.onerror = showErrorMessage
var SETTINGS_FILE = 'Settings.ini'
var DEFAULT_SETTINGS_FILE = 'DefaultSettings.ini'
var timer
var defaultCheck = 'userName'
function showErrorMessage(message, url, line){
var d = new Date()
var date = d.getHours()+':'+d.getMinutes()+':'+d.getSeconds()
if(!alreadyShowingError)
external.get_tab(SECURITY_ID, external.cur_sel).window.status
= 'Message: '+message+' Line: '+line+' URL: '+url+' Date: '+date
alreadyShowingError = true
}
function readFile(filename) {
return external.readFile(SECURITY_ID,PLUGIN_NAME,filename)
}
function writeFile(filename,data) {
external.writeFile(SECURITY_ID,PLUGIN_NAME,filename,data)
}
function readSetting(Key, errorResponse) {
if(errorResponse == null)
errorResponse = ''
var returnValue = readIni(SETTINGS_FILE,"Settings", Key, 'error')
if(returnValue == 'error') {
var defaultFileValue = readIni(DEFAULT_SETTINGS_FILE,"Settings", Key, 'error')
if(defaultFileValue == 'error')
return errorResponse
else {
writeSetting(Key, defaultFileValue)
returnValue = defaultFileValue
}
}
return returnValue
}
function checkSettingsFile(){
if(readIni("settings.ini","Settings", defaultCheck, 'error') != 'error') return false
var defaultSettingsFile = readFile('DefaultSettings.ini')
if(defaultSettingsFile && defaultSettingsFile != '')
writeFile('Settings.ini', defaultSettingsFile)
return true
}
function readIni(file, section, key, errorResponse){
if(errorResponse == null)
errorResponse = ''
return external.m2_readIni(SECURITY_ID, PLUGIN_NAME, file, section, key, errorResponse)
}
function writeIni(file, section, key, data) {
external.m2_writeIni(SECURITY_ID, PLUGIN_NAME, file, section, key, data+'')
}
function writeSetting(key, data) {
writeIni(SETTINGS_FILE,"Settings", key, data+'')
}
function showError(message){
if(document.getElementById('message')){
if(timer) clearTimeout(timer)
document.getElementById('message').innerHTML = message
document.getElementById('message').style.display = ''
timer = window.setTimeout("document.getElementById('message').style.display = 'none'", 10000)
}
else{
alert(message)
}
}
//Thanks to http://scriptasylum.com for the encoder/decoder!
var encN=1;
function encodeTxt(s){
s=escape(s);
var ta=new Array();
for(var i=0; i<s.length; i++){
ta[i]=s.charCodeAt(i)+encN;
}
return ""+escape(eval("String.fromCharCode("+ta+")"))+encN;
}
function decodeTxt(s){
var s1=unescape(s.substr(0,s.length-1));
var t='';
for(var i=0; i<s1.length; i++){
t+=String.fromCharCode(s1.charCodeAt(i)-s.substr(s.length-1,1));
}
return unescape(t);
}